<template>
  <div class="action_item">
    <div class="header">
      <router-link class="user" :to="`/u/${action.domain}`">
        <a-avatar class="user_avatar" :size="25" :src="action.avatar"/>
        <span class="user_name">{{ action.name }}</span>
      </router-link>
      <div class="time">{{ action.createdTime }}</div>
      <div class="description">
        <span v-if="action.type===1">发布了新博客：</span>
        <span v-if="action.type===2">评论了博客：</span>
        &nbsp;<router-link :to="`/blog/${action.blogId}`">{{ action.blogTitle }}</router-link>
      </div>
    </div>
    <div class="content">
      <span v-if="action.type===1">{{ action.blogSummary }}</span>
      <span v-if="action.type===2">
        <span v-if="action.atUserName">回复&nbsp;<a>@{{ action.atUserName }}</a>:&nbsp;</span>
        <span>{{ action.commentContent }}</span>
      </span>
    </div>
  </div>
</template>

<script>
import { defineComponent } from 'vue'

export default defineComponent({
  props: {
    action: {
      type: Object,
      default () {
        return {
          type: '',
          name: '',
          avatar: '',
          domain: '',
          blogId: '',
          blogTitle: '',
          blogSummary: '',
          atUserName: '',
          atUserDomain: '',
          commentContent: '',
          createdTime: ''
        }
      }
    }
  }
})
</script>

<style lang="less" scoped>
& .action_item {
  width: 100%;
  display: flex;
  flex-direction: column;

  & .header {
    margin-top: 10px;
    line-height: 30px;
    font-size: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;

    & .user {
      height: 100%;
      color: #000000;
      display: flex;
      align-items: center;

      & .user_name {
        margin-left: 10px;
        font-weight: 500;
      }
    }

    & .time {
      margin-left: 10px;
      height: 100%;
      display: flex;
      align-items: center;
    }

    & .description {
      margin-left: 10px;
      height: 100%;
      display: flex;
      align-items: center;
    }
  }

  & .content {
    margin: 15px 0 10px 0;
    width: 100%;
    padding: 10px;
    background-color: #00000010;
    border: 1px solid #00000020;
  }
}
</style>
